import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Hump {
    public static void main(String[] args) {
        getTime();
        hump("saGjsGs");
        serpentine("da_dsa_dsw");
        currency("1222322314143343.3112");

    }

    //获取日期
    public static void getTime() {
        LocalDate date = LocalDate.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        String text = date.format(formatter);
        System.out.println(text);
    }

    //蛇型转驼峰
    public static void serpentine(String s) {
        String[] str = s.split("_");
        String newStr = "";
        for (int i = 0; i < str.length; i++) {
            if (i != 0) {
                char[] temp = str[i].toCharArray();
                temp[0] -= 32;
                str[i] = new String(temp);
            }
            newStr += str[i];
        }
        System.out.println(newStr);
    }

    //驼峰转蛇型
    public static void hump(String a) {
        char[] arr = a.toCharArray();
        String str = "";
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 90) {
                str += arr[i];
            } else {
                arr[i] += 32;
                str += "_" + arr[i];
            }
        }
        System.out.println(str);
    }

    //千分位表示货币
    public static void currency(String a) {
        DecimalFormat df = null;
        if (a.indexOf(".") > 0) {
            if (a.length() - a.indexOf(".") - 1 == 0) {
                df = new DecimalFormat("###,##0.");
            } else if (a.length() - a.indexOf(".") - 1 == 1) {
                df = new DecimalFormat("###,##0.0");
            } else {
                df = new DecimalFormat("###,##0.00");
            }
        } else {
            df = new DecimalFormat("###,##0");
        }
        double number = 0.0;
        try {
            number = Double.parseDouble(a);
        } catch (Exception e) {
            number = 0.0;
        }
        System.out.println(df.format(number));
    }
}


